Skip to content

feat(logpoller): use shared framework metrics where applicable#632

Open
jadepark-dev wants to merge 3 commits intomainfrom
jade/lp-framework-metrics
Open

feat(logpoller): use shared framework metrics where applicable#632
jadepark-dev wants to merge 3 commits intomainfrom
jade/lp-framework-metrics

Conversation

@jadepark-dev
Copy link
Collaborator

@jadepark-dev jadepark-dev commented Feb 27, 2026

No description provided.

@jadepark-dev jadepark-dev marked this pull request as ready for review March 4, 2026 14:45
@jadepark-dev jadepark-dev requested a review from a team as a code owner March 4, 2026 14:45
Copilot AI review requested due to automatic review settings March 4, 2026 14:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates TON logpoller observability to use the shared chainlink-framework logpoller metrics where applicable, replacing several TON-specific metrics.

Changes:

  • Replace observed store query/insert metrics with frameworkmetrics.GenericLogPollerMetrics calls (durations, dataset size, logs inserted).
  • Add a “log discovery latency” metric derived from Log.TxTimestamp during SaveLogs.
  • Remove several TON-specific Prometheus/OTel metrics and their helper methods (e.g., query duration/result size, logs/blocks processed).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
pkg/logpoller/service.go Stops emitting the “blocks processed” metric during runs.
pkg/logpoller/observed_log_store.go Switches to framework metrics and adds log discovery latency instrumentation.
pkg/logpoller/observed_filter_store.go Switches query duration/result-size instrumentation to framework metrics.
pkg/logpoller/metrics.go Removes several TON-specific metrics and initializes shared framework logpoller metrics.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

newestTimestamp = l.TxTimestamp
}
}
o.metrics.frameworkMetrics.RecordLogDiscoveryLatency(ctx, time.Since(newestTimestamp).Seconds())
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

time.Since(newestTimestamp) can return a negative duration if TxTimestamp is ahead of the local wall clock (clock skew or differing time sources), which would record a negative discovery latency. Consider clamping the value to >= 0 before emitting the metric to avoid invalid/confusing latency datapoints.

Suggested change
o.metrics.frameworkMetrics.RecordLogDiscoveryLatency(ctx, time.Since(newestTimestamp).Seconds())
latency := time.Since(newestTimestamp)
if latency < 0 {
latency = 0
}
o.metrics.frameworkMetrics.RecordLogDiscoveryLatency(ctx, latency.Seconds())

Copilot uses AI. Check for mistakes.
Comment on lines 289 to 291
lp.lastProcessedBlockSeqNo = blockRange.ToSeqNo()
lp.metrics.SetLastProcessedBlock(ctx, lp.lastProcessedBlockSeqNo)
lp.metrics.AddBlocksProcessed(ctx, int64(blockRange.ToSeqNo()-blockRange.FromSeqNo()))

Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AddBlocksProcessed was removed and there is no replacement call to a shared/framework metric here, so the logpoller will no longer emit any “blocks processed” metric for a successful run. If blocks-processed is still a required SLI, record it via the new frameworkMetrics (or keep the existing metric) rather than dropping it silently; otherwise please update the PR scope/description to clarify the intentional removal.

Copilot uses AI. Check for mistakes.
Comment on lines 50 to 54
// Query metrics for observed stores
promTonLpQueryDuration = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "ton_logpoller_query_duration_seconds",
Help: "Duration of last database query by operation",
}, []string{"chainID", "query", "type"})

promTonLpAddressesMonitored = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "ton_logpoller_addresses_monitored",
Help: "Number of addresses being monitored",
}, []string{"chainID"})
Copy link

Copilot AI Mar 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change removes several Prometheus/OTel query and ingestion metrics (e.g. ton_logpoller_query_duration_seconds, ton_logpoller_query_result_size, and the logs/blocks processed counters) from this package. That is an operationally breaking change for any existing dashboards/alerts scraping the ton_logpoller_* series; consider keeping backward-compatible aliases during a deprecation window or documenting the metric renames/removals as part of the rollout.

Copilot uses AI. Check for mistakes.
@jadepark-dev jadepark-dev requested a review from ogtownsend March 4, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants